{var $colorstyle = dark}
<!DOCTYPE html>
<html>
	<head>
		<title>Tasker</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=8">
		<link rel="stylesheet" type="text/css" href="{$basePath}/css/screen.css">
		<link rel="stylesheet" type="text/css" href="{$basePath}/css/{$colorstyle}/style.css">
		<link rel="stylesheet" type="text/css" href="{$basePath}/css/{$colorstyle}/ui/jquery-ui-1.8.13.custom.css">
		<link rel="stylesheet" type="text/css" href="{$basePath}/jeegoocontext/skins/tasker/style.css">
		<script src="http://code.jquery.com/jquery-1.6.2.js" type="text/javascript"></script>
		<!--<script src="{$basePath}/js/jquery-1.5.1.min.js" type="text/javascript"></script>-->
		<script src="{$basePath}/js/jquery-ui-1.8.13.custom.min.js" type="text/javascript"></script>
		<script src="{$basePath}/js/netteForms.js" type="text/javascript"></script>
		<script src="{$basePath}/js/jquery.nette.js" type="text/javascript"></script>
		<script src="{$basePath}/jeegoocontext/jquery.livequery.min.js"></script>
		<script src="{$basePath}/jeegoocontext/jquery.jeegoocontext.js"></script>
		<script src="{$basePath}/js/custom.js" type="text/javascript"></script>
		{block head}{/block}
		<style>a[href="#"] { background-color: red; color: white; }</style>
	</head>
	<body>
	  {block body}
		<div id="body">
			<div id="logo"><a href="{link :NoticeBoard:}"><img src="{$basePath}/images/{$colorstyle}/logo.png" alt="Tasker" width="106" height="32"></a></div>
			<div id="menu">
				<table id="menucontainer">
					<tr>
						<td id="leftmenu">
							<table>
								<tr>
									<td><table><tr><td><div class="menu_item_sep"></div></td><td><a href="{link :NoticeBoard:}">Nástěnka</a></td><td><div class="menu_item_sep"></div></td></tr></table></td>
									<td><table><tr><td><a href="{link :Project:}">Projekty</a></td><td><div class="menu_item_sep"></div></td></tr></table></td>
									<td><table><tr><td><a href="{link :Task:myTasks}">Moje úkoly</a></td><td><div class="menu_item_sep"></div></td></tr></table></td>
									<td n:if="$user->isAllowed('project','show')"><table><tr><td><a href="{link :Task:}">Všechny úkoly</a></td><td><div class="menu_item_sep"></div></td></tr></table></td>
								</tr>
							</table>
						</td>
						<td id="rightmenu">
							<table>
								<tr>
									<td n:if="$user->isAllowed('administration','show')">
										<table><tr><td><div class="menu_item_sep"></div></td><td><a n:href=":Admin:Default:">Administrace</a></td></tr></table>
									</td>
									<td>
										<table><tr><td><div class="menu_item_sep"></div></td><td><a n:href=":Profile:default">Můj profil</a></td></tr></table>
									</td>
									<td>
										<table><tr><td><div class="menu_item_sep"></div></td><td><a n:href=":Sign:out">Odhlásit se</a></td><td><div class="menu_item_sep"></div></td></tr></table>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</div>
		  {block submenu}{/block}
			<div n:foreach="$flashes as $flash" class="flash {$flash->type}">{!$flash->message}</div>
		  {snippet}
			{include #content}
		  {/snippet}
		</div>
	  {/block}
	</body>
</html>
{define contextMenu}
{default $menuItemCssClass = '.my_tasks_task_line'}
<ul id="tasksContextMenu" class="jeegoocontext cm_default">
	<li class="icon"><span class="icon info"></span><a href="{link :Task:task __id__}">Detail</a></li>
	<li class="icon" data-creator="1"><span class="icon edit"></span><a href="{link Project:editTask __id__}">Upravit</a></li>
	<li class="icon" data-creator="1" data-worker="1">
		<span class="icon status"></span>
		<a>Stav</a>
		<ul id="cm_status">
			{foreach $statuses as $status}
			<li data-value="{$status[id]}"><a href="{link updateCompleted! '__id__','__:value__'}">{$status[name]}</a></li>
			{/foreach}
		</ul>
	</li>
	<li class="icon" data-creator="1" data-worker="1">
		<span class="icon percent"></span>
		<a>Hotovo (%)</a>
		<ul id="cm_completed">
			{var $percents = range(0,100,10)}
			{foreach $percents as $percent}
			<li data-value="{$percent}"{first} class="icon"{/first}>{first}<span class="icon ok"></span>{/first}<a href="{link updateCompleted! '__id__','__:value__'}">{$percent}%</a></li>
			{/foreach}
		</ul>
	</li>
	<li class="icon" data-worker="1">
		<span class="icon priority"></span>
		<a>Vlastní priorita</a>
		<ul>
			<li data-value="NULL"><a href="{link updateUserPriority! '__id__','__:value__'}"><em>Žádná</em></a></li>
			{var $priorities = range(1,10)}
			{foreach $priorities as $priority}
			<li data-value="{$priority}" class="icon"><span class="icon priority{$priority}"></span><a href="{link updateUserPriority! '__id__','__:value__'}">{$priority}</a></li>
			{/foreach}
		</ul>
	</li>
	<li class="icon"><span class="icon favorite"></span><a href="{link switchWatched! '__id__'}">Sledovat</a></li>
</ul>
<script>
	$(function(){
		$(".jeegoocontext a").attr('onclick','return false;');
		var exp = new RegExp(/[a-zA-Z0-9-/]*__([a-z:]+)__[a-zA-Z0-9-/]*/g);
		$({$menuItemCssClass}).jeegoocontext('tasksContextMenu',{
                livequery: true,
				widthOverflowOffset: 0,
                heightOverflowOffset: 1,
                submenuLeftOffset: -4,
                submenuTopOffset: -5,
                onSelect: function(e, context){
					if($(this).hasClass('disabled'))return false;
					var url = $(this).children('a:first').attr('href').replace('%3A',':');
					while((match = exp.exec(url))){
						if(match[1].indexOf(":") === 0){
							var key = match[1].substr(1);
							url = url.replace("__"+match[1]+"__", $(this).data(key))
						}else{
							url = url.replace("__"+match[1]+"__", $(context).data(match[1]))
						}
					}
					window.location.href = url;
                },
                onHover: function(e, context){
                    if($(this).hasClass('disabled'))return false;
                },
				onShow: function(e, context){
					$("#cm_status li").each(function(){
						$(this).children('.icon.ok').remove();
						$(this).removeClass('icon');
						if($(this).data('value') == $(context).data('status')){
							$(this).addClass('icon');
							$(this).prepend('<span class="icon ok"></span>');
						}
					});
					$("#cm_completed li").each(function(){
						$(this).children('.icon.ok').remove();
						$(this).removeClass('icon');
						if($(this).data('value') == $(context).data('completed')){
							$(this).addClass('icon');
							$(this).prepend('<span class="icon ok"></span>');
						}
					});
					$(this).children('li').each(function(){
						if($(this).data('creator') == "1" && $(this).data('worker') == "1"){
							if($(context).data('creator') == "1" || $(context).data('worker') == "1"){
								$(this).removeClass('disabled');
							}else{
								$(this).addClass('disabled');
							}
						}else if($(this).data('creator') == "1"){
							if($(context).data('creator') == "1"){
								$(this).removeClass('disabled');
							}else{
								$(this).addClass('disabled');
							}
						}else if($(this).data('worker') == "1"){
							if($(context).data('worker') == "1"){
								$(this).removeClass('disabled');
							}else{
								$(this).addClass('disabled');
							}
						}else{
							$(this).removeClass('disabled');
						}
					});
				}
            });
		$(".menuImage").click(function(e){
			e.type = "contextmenu.jeegoocontext"; // change click to open menu event
			$(this).trigger(e); // bubble up
		});
	});
</script>
{/define}